package features;


import javax.swing.tree.DefaultMutableTreeNode;

import CAD.MainFrame;

import operationSolids.CSGSolid;
import operationSolids.CompoundSolid;
import operationSolids.OperationRoundFloorPocket;

public class RoundFloorPocket extends Feature{

	int type;
	Feature Mae;
	float radius0, radius1, radius2, radius3, radiusBottom; 
	float d1; 
	float d2;
	float depth; 
	
	public RoundFloorPocket(int type, Feature Mae, float d1, float d2,
			float depth, float posX, float posY, float posZ,
			float radius0, float radius1, float radius2, float radius3, 
			float radiusBottom, String name,int face) 
	{
		super(type, Mae,name);
		
		this.Mae = Mae;
		this.d1 = d1;
		this.d2 = d2;
		this.depth = depth;
		this.radius0 = radius0;
		this.radius1 = radius1;
		this.radius2 = radius2;
		this.radius3 = radius3;
		this.radiusBottom = radiusBottom;
		this.type = type;
		this.name = name;
		
	
		feature=new OperationRoundFloorPocket(name, d1, d2, depth, radius0, radius1, radius2, radius3, radiusBottom);
		feature.rotate(0, 0, 0);
		create(posX, posY, posZ, face);
		MainFrame.features.add(this);
		MainFrame.refreshJTree();
		
		
	}

	public int getType() {
		return type;
	}

	public Feature getMae() {
		return Mae;
	}

	public float getRadius0() {
		return radius0;
	}

	public float getD1() {
		return d1;
	}

	public float getD2() {
		return d2;
	}

	public float getDepth() {
		return depth;
	}

	public CSGSolid getPocket() {
		return feature;
	}
	public float getRadius1() {
		return radius1;
	}

	public void setRadius1(float radius1) {
		this.radius1 = radius1;
	}

	public float getRadius2() {
		return radius2;
	}

	public void setRadius2(float radius2) {
		this.radius2 = radius2;
	}

	public float getRadius3() {
		return radius3;
	}

	public void setRadius3(float radius3) {
		this.radius3 = radius3;
	}

	public float getRadiusBottom() {
		return radiusBottom;
	}

	public void setRadiusBottom(float radiusBottom) {
		this.radiusBottom = radiusBottom;
	}

	public void setRoundPocket(OperationRoundFloorPocket roundPocket) {
		this.feature = roundPocket;
	}

	public void setType(int type) {
		this.type = type;
	}

	public void setMae(Feature mae) {
		Mae = mae;
	}

	public void setRadius0(float radius0) {
		this.radius0 = radius0;
	}

	public void setD1(float d1) {
		this.d1 = d1;
	}

	public void setD2(float d2) {
		this.d2 = d2;
	}

	public void setDepth(float depth) {
		this.depth = depth;
	}

	@Override
	void translate() {
		feature.translate(placement.getX(), placement.getZ() - depth/2,-placement.getY() );
		switch (MainFrame.Face) {
		case MainFrame.BACKFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
			break;
		case MainFrame.FRONTFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
			break;
		case MainFrame.EASTFACE:
			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
			break;
		case MainFrame.WESTFACE:
			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
			break;
		case MainFrame.LOWERFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
			break;
		case MainFrame.TOPFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
			break;

		default:
			System.out.println("erro");
			break;
		}
		
	}

	@Override
	void compound() {
		MainFrame.block  = new Block ("comp", CompoundSolid.DIFFERENCE, MainFrame.block, feature);
	}

	@Override
	public void drawNode(DefaultMutableTreeNode node) {
		node.add(
				new DefaultMutableTreeNode(
				"R1:"+radius0+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"R2:"+radius1+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"R3:"+radius2+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"R4:"+radius3+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"Bottom Radius:"+radiusBottom+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"D1:"+d1+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"D2:"+d2+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"depth:"+depth+"mm")
				);
	}


}

	


